/*
 * 文件名: MonthDayDialog.java
 * 版    权：  Copyright PingAn Technology All Rights Reserved.
 * 描    述: [该类的简要描述]
 * 创建人: EX-XUJIAO001
 * 创建时间: 2012-1-18
 * 
 * 修改人：
 * 修改时间:
 * 修改内容：[修改内容]
 */
package app.widget.calendar.dialog;

import android.content.Context;
import android.view.View;
import app.widget.BaseDialog;


/**
 * @author EX-XUJIAO001
 * @date 2012-1-18
 * @version [Android PABank C01, @2012-1-18]
 * @description 月日dialog
 */
public class MonthDayDialog extends BaseDialog {
	/**
	 * 返回的View
	 */
	private View contentView;
	/**
	 * 上下文
	 */
	private Context context;
	/**
	 * 月
	 */
	private int mMonth;
	/**
	 * 日
	 */
	private int mDay;

	/**
	 * 
	 * [构造简要说明]
	 * 
	 * @param context
	 *            上下文
	 * @param title
	 *            标题
	 */
	public MonthDayDialog(Context context, String title) {
		super(context);
		this.context = context;
		setTitle(title);
		initData();
	}

	/**
	 * 
	 * [一句话功能简述]<BR>
	 * [功能详细描述] 初始化
	 */
	private void initData() {
		MonthDayLinearLayout monthDayLinearLayout = new MonthDayLinearLayout(
				context);
		contentView = monthDayLinearLayout;
		monthDayLinearLayout
				.setOnMonthDayScrollListener(new MonthDayLinearLayout.OnMonthDayScrollListener() {

					@Override
					public void onMonthDayScrollEnd(boolean scrollState) {
						if (scrollState) {
							setBtn1Enable(false);
							setBtn2Enable(false);
						} else {
							setBtn1Enable(true);
							setBtn2Enable(true);
						}

					}

					@Override
					public void onMonthDayScrollChange(int month, int day) {
						mMonth = month;
						mDay = day;
					}

				});

		setBtn1ClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {

				if (onMonthDayScrollListener != null) {
					onMonthDayScrollListener.onMonthDayScroll(mMonth, mDay);
				}
				MonthDayDialog.this.dismiss();
			}
		});

		setBtn2ClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				MonthDayDialog.this.dismiss();
			}
		});

	}

	@Override
	public View createContentView() {

		return contentView;
	}

	/**
	 * 
	 * [一句话功能简述]<BR>
	 * [功能详细描述]
	 * 
	 * @author EX-XUJIAO001
	 * @version [Android PABank C01, 2012-1-18]
	 */
	public interface OnMonthDayScrollListener {
		/**
		 * 
		 * [一句话功能简述]<BR>
		 * [功能详细描述]
		 * 
		 * @param month
		 *            年
		 * @param day
		 *            月
		 */
		void onMonthDayScroll(int month, int day);
	}

	/**
	 * 回调监听器
	 */
	private OnMonthDayScrollListener onMonthDayScrollListener;

	/**
	 * 
	 * [一句话功能简述]<BR>
	 * [功能详细描述] setter
	 * 
	 * @param onMonthDayScrollListener
	 *            回调监听器
	 */
	public void setOnMonthDayScrollListener(
			OnMonthDayScrollListener onMonthDayScrollListener) {
		this.onMonthDayScrollListener = onMonthDayScrollListener;
	}

	/**
	 * 
	 * [一句话功能简述]<BR>
	 * [功能详细描述] getter
	 * 
	 * @return OnMonthDayScrollListener
	 */
	public OnMonthDayScrollListener getOnMonthDayScrollListener() {
		return onMonthDayScrollListener;
	}

}
